package StudyCode.summary.aclfile;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ReadBytesFromFile {
	public static void main(String[] argv) throws Exception {
		File file = new File("E:/Copy/1.txt");
		System.out.println(Arrays.toString(readBytesFromFile(file)));
	}


	private static byte[] readBytesFromFile(File grammarFile) throws IOException {
		byte[] oldBytes = null;
		if (grammarFile.exists()) {
			FileReader reader = new FileReader(grammarFile);
			ByteArrayOutputStream oldBytesStream = new ByteArrayOutputStream();
			while (reader.ready()) {
				oldBytesStream.write(reader.read());
			}
			oldBytesStream.flush();
			oldBytes = oldBytesStream.toByteArray();
			oldBytesStream.close();
		}
		return oldBytes;
	}
}
